// app.js
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        let code=res.code
          // 通过code换取openId
          wx.request({
          url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx281cc4fd23e3172e&secret=6393144393db952a4c2f0de26719591d&js_code=${code}&grant_type=authorization_code`,
          success:(res)=>{

            this.globalData.employId = res.data.openid
            if (this.employIdCallback){
              this.employIdCallback(res.data.openid);
            }
           }
        })
      }
    })
  },
  globalData: {
    userInfo: null,
    employId: null,
    host: "http://localhost:8080"
  }
})
